/**
 * 
 */
package org.jftstool.config;

import java.util.ArrayList;
import java.util.List;

/**
 * @author grupo JFTS
 *
 */
public class SemanticConfig {
	private String ontologyFile = null;
	private String nameSpace = null;
	private String classInferenceClass = null;
	private String patternFile = null;
	private String unknownClass = null;
	private int analyzeMaxLength = 0;	
	private List<String> classMapping = null;	
	private List<DBConnectionConfig> dbModelConnections = null;
	
	
	public SemanticConfig() {
		dbModelConnections = new ArrayList<DBConnectionConfig>();
		classMapping = new ArrayList<String>();		
	}

	
	public SemanticConfig(String ontologyFile, String nameSpace, String classInferenceClass,
			String patternFile, String unknownFile, int analyzeMaxLength, List<String> classMapping,
			List<DBConnectionConfig> dbModelConnections) {
		
		this.ontologyFile = ontologyFile;
		this.nameSpace = nameSpace;
		this.classInferenceClass = classInferenceClass;
		this.patternFile = patternFile;
		this.unknownClass = unknownFile;
		this.analyzeMaxLength = analyzeMaxLength;
		this.classMapping = classMapping;
		this.dbModelConnections = dbModelConnections;
	}


	public String getOntologyFile() {
		return ontologyFile;
	}


	public void setOntologyFile(String ontologyFile) {
		this.ontologyFile = ontologyFile;
	}


	public String getNameSpace() {
		return nameSpace;
	}


	public void setNameSpace(String nameSpace) {
		this.nameSpace = nameSpace;
	}


	public DBConnectionConfig getModelDBConn(String name){
		DBConnectionConfig result = null;
		for (DBConnectionConfig conn : dbModelConnections){
			if (conn.getArg("type").equalsIgnoreCase(name)){
				result = conn;
				break;
			}
		}
		return result;
	}
	
	public DBConnectionConfig getDefaultDBConn(){
		DBConnectionConfig result = null;
		String aux = null;
		for (DBConnectionConfig conn : dbModelConnections){
			aux = conn.getArg("default").trim();
			if (aux != null){
				if (Boolean.parseBoolean(aux)){
					result = conn;
					break;
				}
			}
		}
		return result;
	}	

	
	public void setDbModelConnections(List<DBConnectionConfig> dbModelConnections) {
		this.dbModelConnections = dbModelConnections;
	}


	public List<String> getClassMapping() {
		return classMapping;
	}


	public void setClassMapping(List<String> classMapping) {
		this.classMapping = classMapping;
	}


	public String getClassInferenceClass() {
		return classInferenceClass;
	}


	public void setClassInferenceClass(String classInferenceClass) {
		this.classInferenceClass = classInferenceClass;
	}


	public String getPatternFile() {
		return patternFile;
	}


	public void setPatternFile(String patternFile) {
		this.patternFile = patternFile;
	}


	public String getUnknownClass() {
		return unknownClass;
	}


	public void setUnknownClass(String unknownClass) {
		this.unknownClass = unknownClass;
	}


	public int getAnalyzeMaxLength() {
		return analyzeMaxLength;
	}


	public void setAnalyzeMaxLength(int analyzeMaxLength) {
		this.analyzeMaxLength = analyzeMaxLength;
	}
}